package com.ruoyi.system.outto.game.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.model.domain.AccountInfo;
import com.ruoyi.system.model.domain.InfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.mapper.AccountInfoMapper;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.MapUntils;
import com.ruoyi.system.outto.dto.LSHENConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.LDAPI;
import com.ruoyi.system.outto.game.LSHENAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.Md5Crypt;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/5 16:19
 */
@Slf4j
@Service
public class LSHENAPIImpl implements LSHENAPI {

    @Resource
    private InfoImgMapper infoImgMapper;
    @Value("${desc.title}")
    private String descTitle;
    private SalePartner salePartner;
    @Resource
    private CommonApi commonApi;

    private static String baseUrl = "http://test-www.leishenshangcheng.com/webapi";

    @Resource
    private AccountInfoMapper accountInfoMapper;


    @Override
    public AjaxResult addGame(AccountInfo accountInfo, Long userId, SalePartner salePartner) {

        String path = "/apiProduct/push";
        this.salePartner = salePartner;
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> params = params(accountInfo);
        log.info("雷神添加接口请求参数={}", JSONObject.toJSONString(params));
        Map<String, Object> header = new HashMap<>();
        header.put("reqChannel", 4);
        String response = HttpUtils.doPostForm(salePartner.getTwoOther() + path, params, header);
        log.info("雷神添加接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!"true".equals(resultJson.getString("success"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
            JSONObject data = resultJson.getJSONObject("retData");
            String goodsNo = data.getString("goodsNo");
            AccountInfo info = accountInfoMapper.selectAccountInfoById(accountInfo.getId());
            info.setLeishenid(goodsNo);
            accountInfoMapper.updateAccountInfo(info);
            upGame(goodsNo, salePartner);
        }

        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));

        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(AccountInfo accountInfo, Long userId, SalePartner salePartner) {
        String path = "/apiProduct/edit";
        this.salePartner = salePartner;
        Map<String, Object> result = new HashMap<>();

        Map<String, Object> header = new HashMap<>();
        header.put("reqChannel", 4);

        Map<String, Object> map = new HashMap<>();

        List<Map<String, Object>> goodsList = new ArrayList<>();
        accountInfo.setDes("xyr" + accountInfo.getId() + " " + accountInfo.getLevel() + accountInfo.getDes());
        String des = accountInfo.getDes();
        Map<String, Object> params = new HashMap<>();
        params.put("goodsNo", accountInfo.getLeishenid());
        BigDecimal bigDecimal = commonApi.addPrice(accountInfo.getPrice(),  this.salePartner.getSeleep());
        commonApi.setPrice(bigDecimal,accountInfo.getId(), this.salePartner);
        params.put("salePrice", bigDecimal);
        params.put("stock", "1");
        params.put("goodsDesc", accountInfo.getDes());
        params.put("compensation", "1");
        String regional = accountInfo.getRegional();
        List<JSONObject> goodsAttrList = new ArrayList<>();
        if (Objects.equals("王者荣耀", accountInfo.getType())) {

            String gameName = "";
            if (des.length() > 100) {
                gameName = des.substring(0, 100);
            } else {
                gameName = des;
            }

            params.put("goodsTitle", gameName);
//            params.put("goodsTitle", descTitle + "||" + accountInfo.getId() + "【皮肤数量 " + accountInfo.getSkins() + "英雄数量 " + accountInfo.getHeroes() + "】");

            params.put("gameId", "67");
            params.put("systemId", "65");

            if (Objects.equals("安卓Q", regional)) {

                params.put("gameSysId", "65");
                params.put("gameServerId", "55");


            } else if (Objects.equals("安卓WX", regional)) {

                params.put("gameSysId", "65");
                params.put("gameServerId", "56");

            } else if (Objects.equals("苹果WX", regional)) {
                params.put("gameSysId", "66");
                params.put("gameServerId", "54");
            } else if (Objects.equals("苹果Q", regional)) {
                params.put("gameSysId", "66");
                params.put("gameServerId", "53");
            } else {
                return null;
            }
            params.put("gameName", "【皮肤数量 " + accountInfo.getSkins() + "英雄数量 " + accountInfo.getHeroes() + "】");

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();


            String wzryxiyou = LSHENConstant.wzryxiyou;
            List<JSONObject> jsonObjects = JSONObject.parseArray(wzryxiyou, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 229);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);

            }
            ids.clear();


            JSONObject duanwei = new JSONObject();
            String duanweiStr = LSHENConstant.duanwei;
            jsonObjects = JSONObject.parseArray(duanweiStr, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 217);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();


            //皮肤
            JSONObject pifujson = new JSONObject();
            pifujson.put("gameParentAttrId", 212);
            pifujson.put("gameChildAttrValue", accountInfo.getSkins());
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 20) {
//                ids.add(213l);
//            }
//            if (accountInfo.getHeroes() > 21 && accountInfo.getHeroes() <= 50) {
//                ids.add(214l);
//            }
//            if (accountInfo.getHeroes() > 51 && accountInfo.getHeroes() <= 80) {
//                ids.add(215l);
//            }
//            if (accountInfo.getHeroes() > 80 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(216l);
//            }
//            if (CollectionUtils.isNotEmpty(ids)) {
//                String join = StringUtils.join(ids, ",");
//                pifujson.put("gameChildAttrId", join);
//            }
            goodsAttrList.add(pifujson);
            ids.clear();

            //贵族
            JSONObject guizujson = new JSONObject();
            String v1 = "V1";
            String v2 = "V2";
            String v3 = "V3";
            String v4 = "V4";
            String v5 = "V5";
            String v6 = "V6";
            String v7 = "V7";
            String v8 = "V8";
            String v9 = "V9";
            String v10 = "V9";

            if (accountInfo.getDes().contains(v1) ||
                    accountInfo.getDes().contains(v2) ||
                    accountInfo.getDes().contains(v3) ||
                    accountInfo.getDes().contains(v4) ||
                    accountInfo.getDes().contains(v5) ||
                    accountInfo.getDes().contains(v6)
            ) {
                ids.add(208l);
            }

            if (accountInfo.getDes().contains(v7)) {
                ids.add(209l);
            }
            if (accountInfo.getDes().contains(v8)) {
                ids.add(210l);
            }
            if (accountInfo.getDes().contains(v9)) {
                ids.add(211l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                guizujson.put("gameParentAttrId", 207);
                String join = StringUtils.join(ids, ",");
                guizujson.put("gameChildAttrId", join);
                goodsAttrList.add(guizujson);
            }
            ids.clear();


            JSONObject skinjson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 50) {
//                ids.add(203l);
//            }
//            if (accountInfo.getHeroes() > 51 && accountInfo.getHeroes() <= 150) {
//                ids.add(204l);
//            }
//            if (accountInfo.getHeroes() > 150 && accountInfo.getHeroes() <= 300) {
//                ids.add(205l);
//            }
//            if (accountInfo.getHeroes() > 300 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(206l);
//            }
            if (CollectionUtils.isNotEmpty(ids)) {
                skinjson.put("gameParentAttrId", 202);
//                String join = StringUtils.join(ids, ",");
                skinjson.put("gameChildAttrValue", accountInfo.getHeroes());
                goodsAttrList.add(skinjson);
            }
            ids.clear();


            //沉迷
            JSONObject chenmijson = new JSONObject();
            chenmijson.put("gameParentAttrId", 199);
            ids.add(201l);
            if (CollectionUtils.isNotEmpty(ids)) {
                String join = StringUtils.join(ids, ",");
                chenmijson.put("gameChildAttrId", join);
            }
            goodsAttrList.add(chenmijson);

            ids.clear();

            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(197l);
            } else {
                ids.add(198l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 196);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();


            JSONObject wzxiyouskinjson = new JSONObject();
            String wzryxiyouskins = LSHENConstant.wzryxiyouskins;

            jsonObjects = JSONObject.parseArray(wzryxiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiyouskinjson.put("gameParentAttrId", 142);
                String join = StringUtils.join(ids, ",");
                wzxiyouskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiyouskinjson);
            }
            ids.clear();

            //限定皮肤
            JSONObject wzxiandingskinjson = new JSONObject();
            String xiandingskins = LSHENConstant.xiandingskins;

            jsonObjects = JSONObject.parseArray(xiandingskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiandingskinjson.put("gameParentAttrId", 28);
                String join = StringUtils.join(ids, ",");
                wzxiandingskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiandingskinjson);
            }
            ids.clear();


            //星元皮肤
            JSONObject wzxingyuanskinjson = new JSONObject();
            String wzxingyuanskins = LSHENConstant.wzxingyuanskins;

            jsonObjects = JSONObject.parseArray(wzxingyuanskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxingyuanskinjson.put("gameParentAttrId", 16);
                String join = StringUtils.join(ids, ",");
                wzxingyuanskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxingyuanskinjson);
            }
            ids.clear();

            //典藏皮肤
            JSONObject wzdiancnagskinjson = new JSONObject();
            String diancangskins = LSHENConstant.diancangskins;

            jsonObjects = JSONObject.parseArray(diancangskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzdiancnagskinjson.put("gameParentAttrId", 1);
                String join = StringUtils.join(ids, ",");
                wzdiancnagskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzdiancnagskinjson);
            }
            ids.clear();

        }
        if (Objects.equals("和平精英", accountInfo.getType())) {
//            params.put("goodsTitle", descTitle + "||" + accountInfo.getId() + "【枪皮数量 " + accountInfo.getGuns() + "套装数量 " + accountInfo.getSuit() + "】");
            String gameName = "";
            if (des.length() > 100) {
                gameName = des.substring(0, 100);
            } else {
                gameName = des;
            }
            params.put("goodsTitle", gameName);

            params.put("gameId", "68");

            if (Objects.equals("安卓Q", regional)) {

                params.put("gameSysId", "67");
                params.put("gameServerId", "59");
            } else if (Objects.equals("安卓WX", regional)) {

                params.put("gameSysId", "67");
                params.put("gameServerId", "60");
            } else if (Objects.equals("苹果WX", regional)) {
                params.put("gameSysId", "68");
                params.put("gameServerId", "57");
            } else if (Objects.equals("苹果Q", regional)) {
                params.put("gameSysId", "68");
                params.put("gameServerId", "58");
            } else {
                return null;
            }
            params.put("gameName", gameName);

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String wzryxiyou = LSHENConstant.xiyoutaozhuang;
            List<JSONObject> jsonObjects = JSONObject.parseArray(wzryxiyou, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 389);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            JSONObject duanwei = new JSONObject();
            String duanweiStr = LSHENConstant.hpduanwei;
            jsonObjects = JSONObject.parseArray(duanweiStr, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 267);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getGuns() > -1 && accountInfo.getGuns() <= 5) {
//                ids.add(261l);
//            }
//            if (accountInfo.getGuns() > 6 && accountInfo.getGuns() <= 10) {
//                ids.add(262l);
//            }
//            if (accountInfo.getGuns() > 11 && accountInfo.getGuns() <= 20) {
//                ids.add(263l);
//            }
//            if (accountInfo.getGuns() > 21 && accountInfo.getGuns() <= 30) {
//                ids.add(264l);
//            }
//            if (accountInfo.getGuns() > 31 && accountInfo.getGuns() <= 45) {
//                ids.add(265l);
//            }
//            if (accountInfo.getGuns() > 45 && accountInfo.getGuns() <= 9999999) {
//                ids.add(266l);
//            }
            pifujson.put("gameParentAttrId", 260);
            pifujson.put("gameChildAttrValue", accountInfo.getGuns());
            goodsAttrList.add(pifujson);
            ids.clear();

            //贵族
            JSONObject guizujson = new JSONObject();
            String v1 = "V1";
            String v2 = "V2";
            String v3 = "V3";
            String v4 = "V4";
            String v5 = "V5";
            String v6 = "V6";
            String v7 = "V7";
            String v8 = "V8";
            String v9 = "V9";
            String v10 = "V9";

            if (accountInfo.getDes().contains(v1) ||
                    accountInfo.getDes().contains(v2) ||
                    accountInfo.getDes().contains(v3) ||
                    accountInfo.getDes().contains(v4) ||
                    accountInfo.getDes().contains(v5) ||
                    accountInfo.getDes().contains(v6)
            ) {
                ids.add(208l);
            }

            if (accountInfo.getDes().contains(v7)) {
                ids.add(209l);
            }
            if (accountInfo.getDes().contains(v8)) {
                ids.add(210l);
            }
            if (accountInfo.getDes().contains(v9)) {
                ids.add(211l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                String join = StringUtils.join(ids, ",");
                guizujson.put("gameChildAttrId", join);
                guizujson.put("gameParentAttrId", 207);
                goodsAttrList.add(guizujson);
            }
            ids.clear();

            JSONObject skinjson = new JSONObject();
//            if (accountInfo.getSuit() > -1 && accountInfo.getSuit() <= 50) {
//                ids.add(245l);
//            }
//            if (accountInfo.getSuit() > 51 && accountInfo.getSuit() <= 100) {
//                ids.add(246l);
//            }
//            if (accountInfo.getSuit() > 101 && accountInfo.getSuit() <= 150) {
//                ids.add(247l);
//            }
//            if (accountInfo.getSuit() > 151 && accountInfo.getSuit() <= 250) {
//                ids.add(248l);
//            }
//            if (accountInfo.getSuit() > 251 && accountInfo.getSuit() <= 351) {
//                ids.add(249l);
//            }
//            if (accountInfo.getSuit() > 351 && accountInfo.getSuit() <= 450) {
//                ids.add(250l);
//            }
//            if (accountInfo.getSuit() > 450 && accountInfo.getSuit() <= 99999999) {
//                ids.add(251l);
//            }

            skinjson.put("gameParentAttrId", 244);
            skinjson.put("gameChildAttrId", accountInfo.getSuit());
            goodsAttrList.add(skinjson);

            ids.clear();

            //沉迷
            JSONObject chenmijson = new JSONObject();
            ids.add(243l);
            if (CollectionUtils.isNotEmpty(ids)) {
                chenmijson.put("gameParentAttrId", 241);
                String join = StringUtils.join(ids, ",");
                chenmijson.put("gameChildAttrId", join);
                goodsAttrList.add(chenmijson);
            }
            ids.clear();

            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(239l);
            } else {
                ids.add(240l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 238);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();

            JSONObject wzxiyouskinjson = new JSONObject();
            String wzryxiyouskins = LSHENConstant.remenqix;

            jsonObjects = JSONObject.parseArray(wzryxiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiyouskinjson.put("gameParentAttrId", 334);
                String join = StringUtils.join(ids, ",");
                wzxiyouskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiyouskinjson);
            }
            ids.clear();

            //限定皮肤
            JSONObject wzxiandingskinjson = new JSONObject();
            String wzryxiandingskins = LSHENConstant.remzju;

            jsonObjects = JSONObject.parseArray(wzryxiandingskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiandingskinjson.put("gameParentAttrId", 276);
                String join = StringUtils.join(ids, ",");
                wzxiandingskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiandingskinjson);
            }
        }
        if (Objects.equals("原神", accountInfo.getType())) {

            String gameName = "";
            if (des.length() > 100) {
                gameName = des.substring(0, 100);
            } else {
                gameName = des;
            }

            params.put("goodsTitle", descTitle + "||" + accountInfo.getId() + gameName);

            params.put("gameId", "69");

            params.put("gameSysId", "70");
            if (Objects.equals("官服", accountInfo.getRegional())) {
                params.put("gameServerId", "65");
            }
            if (Objects.equals("B服", accountInfo.getRegional())) {
                params.put("gameServerId", "66");
            }
            params.put("gameName", gameName);

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String ys5xing = LSHENConstant.ys5xing;
            List<JSONObject> jsonObjects = JSONObject.parseArray(ys5xing, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 543);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 5) {
//                ids.add(538l);
//            }
//            if (accountInfo.getHeroes() > 6 && accountInfo.getHeroes() <= 10) {
//                ids.add(539l);
//            }
//            if (accountInfo.getHeroes() > 11 && accountInfo.getHeroes() <= 20) {
//                ids.add(540l);
//            }
//            if (accountInfo.getHeroes() > 21 && accountInfo.getHeroes() <= 30) {
//                ids.add(541l);
//            }
//            if (accountInfo.getHeroes() > 31 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(542l);
//            }
            pifujson.put("gameParentAttrId", 537);
            pifujson.put("gameChildAttrValue", accountInfo.getHeroes());
            goodsAttrList.add(pifujson);
            ids.clear();

            //5星角色数量
            JSONObject juese = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 5) {
//                ids.add(532l);
//            }
//            if (accountInfo.getHeroes() > 6 && accountInfo.getHeroes() <= 10) {
//                ids.add(533l);
//            }
//            if (accountInfo.getHeroes() > 11 && accountInfo.getHeroes() <= 15) {
//                ids.add(534l);
//            }
//            if (accountInfo.getHeroes() > 15 && accountInfo.getHeroes() <= 25) {
//                ids.add(535l);
//            }
//            if (accountInfo.getHeroes() > 25 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(536l);
//            }
            juese.put("gameParentAttrId", 531);
            juese.put("gameChildAttrValue", accountInfo.getSkins());
            goodsAttrList.add(juese);
            ids.clear();


            JSONObject shiming = new JSONObject();
            if (!Objects.equals(LCConstant.kehuanMial, accountInfo.getLevel())) {
                ids.add(526l);
            } else {
                ids.add(525l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 524);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();
        }
        if (Objects.equals("英雄联盟", accountInfo.getType())) {
            params.put("goodsTitle", descTitle + "||" + accountInfo.getId() + "【英雄数量 " + accountInfo.getHeroes() + "皮肤数量 " + accountInfo.getHeroes() + "】");

            params.put("gameId", "71");
            params.put("gameSysId", "71");

            String lccLOLr = LSHENConstant.lolr;
            JSONObject lOLrObject = JSONObject.parseObject(lccLOLr);
            String lOLrObjectArr = lOLrObject.getString("retData");
            List<JSONObject> rList = JSONObject.parseArray(lOLrObjectArr, JSONObject.class);
            for (JSONObject jsonObject : rList) {
                String gameServerVoList = jsonObject.getString("gameServerVoList");
                List<JSONObject> serverVoListJson = JSONObject.parseArray(gameServerVoList, JSONObject.class);
                for (JSONObject areaJson : serverVoListJson) {

                    String serverId = areaJson.getString("serverId");

                    String gameAreaVoList = areaJson.getString("gameAreaVoList");
                    List<JSONObject> areaJsonList = JSONObject.parseArray(gameAreaVoList, JSONObject.class);
                    for (JSONObject gameArea : areaJsonList) {
                        String areaName = gameArea.getString("areaName");
                        if (Objects.equals(accountInfo.getLevel(), areaName)) {
                            params.put("gameServerId", serverId);
                            params.put("gameAreaId", gameArea.getString("areaId"));
                        }
                    }
                }
            }
            String gameName = "";
            if (des.length() > 100) {
                gameName = des.substring(0, 100);
            } else {
                gameName = des;
            }
            params.put("gameName", gameName);
//            params.put("gameName", "【英雄数量：" + accountInfo.getHeroes() + " 皮肤数量：" + accountInfo.getSkins() );

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String hksskin = LSHENConstant.hksskin;
            List<JSONObject> jsonObjects = JSONObject.parseArray(hksskin, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 688);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();


            JSONObject duanwei = new JSONObject();
            String zhskins = LSHENConstant.zhskins;
            jsonObjects = JSONObject.parseArray(zhskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 661);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();

            JSONObject xiyou = new JSONObject();
            String xiyouskins = LSHENConstant.xiyouskins;
            jsonObjects = JSONObject.parseArray(xiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyou.put("gameParentAttrId", 653);
                String join = StringUtils.join(ids, ",");
                xiyou.put("gameChildAttrId", join);
                goodsAttrList.add(xiyou);
            }
            ids.clear();

            JSONObject chenmin = new JSONObject();
            chenmin.put("gameParentAttrId", 634);
            chenmin.put("gameChildAttrId", 636);
            goodsAttrList.add(chenmin);

            ids.clear();
            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(992l);
            } else {
                ids.add(993l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 991);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 30) {
//                ids.add(629l);
//            }
//            if (accountInfo.getHeroes() > 31 && accountInfo.getHeroes() <= 60) {
//                ids.add(630l);
//            }
//            if (accountInfo.getHeroes() > 61 && accountInfo.getHeroes() <= 100) {
//                ids.add(631l);
//            }
//            if (accountInfo.getHeroes() > 101 && accountInfo.getHeroes() <= 150) {
//                ids.add(632l);
//            }
//            if (accountInfo.getHeroes() > 150 && accountInfo.getHeroes() <= 999999) {
//                ids.add(633l);
//            }
            pifujson.put("gameParentAttrId", 628);
            pifujson.put("gameChildAttrValue", accountInfo.getSkins());
            goodsAttrList.add(pifujson);
            ids.clear();
            //皮肤
            pifujson.put("gameParentAttrId", 621);
            String join = StringUtils.join(ids, ",");
            pifujson.put("gameChildAttrValue", accountInfo.getHeroes());
            goodsAttrList.add(pifujson);
        }
        if (Objects.equals("CF端游", accountInfo.getType())) {

            String gameName = "";
            if (des.length() > 15) {
                gameName = des.substring(0, 100);
            } else {
                gameName = des;
            }

            params.put("goodsTitle", descTitle + "||" + accountInfo.getId() + gameName);

            params.put("gameId", "72");

            params.put("gameSysId", "69");
            if (Objects.equals("东部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "61");
            }
            if (Objects.equals("南部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "62");
            }
            if (Objects.equals("西部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "63");
            }
            if (Objects.equals("北部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "64");
            }
            params.put("gameName", gameName);

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String ys5xing = LSHENConstant.cfvq;
            List<JSONObject> jsonObjects = JSONObject.parseArray(ys5xing, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 467);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            JSONObject chenmi = new JSONObject();
            chenmi.put("gameParentAttrId", 443);
            chenmi.put("gameChildAttrId", 445);
            goodsAttrList.add(chenmi);

            ids.clear();
            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(441l);
            } else {
                ids.add(442l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 440);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }
            ids.clear();
        }
        params.put("compensation", "1");
        params.put("channelProductCode", accountInfo.getId());
        params.put("goodsType", "0");
        params.put("qty", "0");
        goodsList.add(params);
        map.put("goodsList", goodsList);

//        String appKey = "yuduwangluo";
//        String appSecret = "kbcyRN68obBkdwXIbwZ7eRks14tM1AsI";
        String appKey = salePartner.getSaleKey();
        String appSecret = salePartner.getOther();
        String version = "1.0";
        String timestamp = String.valueOf(new Date().getTime() / 1000);
        Map<String, Object> paramReq = new HashMap<>();
        paramReq.put("appKey", appKey);
        paramReq.put("timestamp", timestamp);
        paramReq.put("version", version);
        paramReq.put("paramJson", JSONObject.toJSONString(map));
        log.info("paramJson={}", JSONObject.toJSONString(map));

        String sign = algSign(appKey, appSecret, timestamp, version, JSONObject.toJSONString(map));
//        params.put("sign", sign);
        paramReq.put("sign", sign);


        log.info("雷神编辑接口请求参数={}", JSONObject.toJSONString(paramReq));
        String response = HttpUtils.doPostForm(salePartner.getTwoOther() + path, paramReq, header);
        log.info("雷神编辑接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);

        if (!"true".equals(resultJson.getString("success"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
        }


        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));
        return AjaxResult.success(result);
    }


    private Map<String, Object> params(AccountInfo accountInfo) {

        accountInfo.setDes(descTitle + accountInfo.getId() + " " + accountInfo.getLevel() + accountInfo.getDes());

        Map<String, Object> params = new LinkedHashMap<>();

        InfoImg infoImg = new InfoImg();
        infoImg.setInfoId(accountInfo.getId());
        infoImg.setType(Constants.STR_1);
        List<InfoImg> infoImgs = infoImgMapper.selectInfoImgList(infoImg);
        int i = 0;
        List<Object> goodsPicList = new ArrayList<>();
        JSONObject picOne = new JSONObject();
        picOne.put("picUrl", accountInfo.getTitleImg());
        picOne.put("sort", i);
        goodsPicList.add(picOne);
        for (InfoImg img : infoImgs) {
            i++;
            JSONObject pic = new JSONObject();
            pic.put("picUrl", img.getImgUrl());
            pic.put("sort", i);
            goodsPicList.add(pic);
        }
        params.put("goodsPicList", goodsPicList);

        params.put("imgUrl", accountInfo.getTitleImg());
        params.put("gameAccount", "111111");
        params.put("salePrice", accountInfo.getPrice());
        BigDecimal bigDecimal = accountInfo.getPrice();
        BigDecimal subtract = new BigDecimal(100).subtract(new BigDecimal(80));
        BigDecimal divide = subtract.divide(new BigDecimal(100));
        BigDecimal subLinePrice = bigDecimal.add(bigDecimal.multiply(divide));
        params.put("subLinePrice",subLinePrice);
        String des = accountInfo.getDes();
        if (StringUtils.isEmpty(des)) {
            des = "---";
        }

        List<JSONObject> goodsAttrList = new ArrayList<>();

        String gameName = "";
        if (des.length() > 100) {
            gameName = des.substring(0, 100);
        } else {
            gameName =  des;
        }

        String regional = accountInfo.getRegional();
        if (Objects.equals("王者荣耀", accountInfo.getType())) {
            params.put("goodsTitle", gameName);

            params.put("gameId", "67");
            params.put("systemId", "65");

            if (Objects.equals("安卓Q", regional)) {

                params.put("gameSysId", "65");
                params.put("gameServerId", "55");


            } else if (Objects.equals("安卓WX", regional)) {

                params.put("gameSysId", "65");
                params.put("gameServerId", "56");

            } else if (Objects.equals("苹果WX", regional)) {
                params.put("gameSysId", "66");
                params.put("gameServerId", "54");
            } else if (Objects.equals("苹果Q", regional)) {
                params.put("gameSysId", "66");
                params.put("gameServerId", "53");
            } else {
                return null;
            }
            params.put("gameName", "【皮肤数量 " + accountInfo.getSkins() + "英雄数量 " + accountInfo.getHeroes() + "】");

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();


            String wzryxiyou = LSHENConstant.wzryxiyou;
            List<JSONObject> jsonObjects = JSONObject.parseArray(wzryxiyou, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 229);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);

            }
            ids.clear();


            JSONObject duanwei = new JSONObject();
            String duanweiStr = LSHENConstant.duanwei;
            jsonObjects = JSONObject.parseArray(duanweiStr, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 217);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();


            //皮肤
            JSONObject pifujson = new JSONObject();
            pifujson.put("gameParentAttrId", 212);
            pifujson.put("gameChildAttrValue", accountInfo.getHeroes());
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 20) {
//                ids.add(213l);
//            }
//            if (accountInfo.getHeroes() > 21 && accountInfo.getHeroes() <= 50) {
//                ids.add(214l);
//            }
//            if (accountInfo.getHeroes() > 51 && accountInfo.getHeroes() <= 80) {
//                ids.add(215l);
//            }
//            if (accountInfo.getHeroes() > 80 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(216l);
//            }
//            if (CollectionUtils.isNotEmpty(ids)) {
//                String join = StringUtils.join(ids, ",");
//                pifujson.put("gameChildAttrValue", join);
//            }
            goodsAttrList.add(pifujson);
            ids.clear();

            //贵族
            JSONObject guizujson = new JSONObject();
            String v1 = "V1";
            String v2 = "V2";
            String v3 = "V3";
            String v4 = "V4";
            String v5 = "V5";
            String v6 = "V6";
            String v7 = "V7";
            String v8 = "V8";
            String v9 = "V9";
            String v10 = "V9";

            if (accountInfo.getDes().contains(v1) ||
                    accountInfo.getDes().contains(v2) ||
                    accountInfo.getDes().contains(v3) ||
                    accountInfo.getDes().contains(v4) ||
                    accountInfo.getDes().contains(v5) ||
                    accountInfo.getDes().contains(v6)
            ) {
                ids.add(208l);
            }

            if (accountInfo.getDes().contains(v7)) {
                ids.add(209l);
            }
            if (accountInfo.getDes().contains(v8)) {
                ids.add(210l);
            }
            if (accountInfo.getDes().contains(v9)) {
                ids.add(211l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                guizujson.put("gameParentAttrId", 207);
                String join = StringUtils.join(ids, ",");
                guizujson.put("gameChildAttrId", join);
                goodsAttrList.add(guizujson);
            }
            ids.clear();


            JSONObject skinjson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 50) {
//                ids.add(203l);
//            }
//            if (accountInfo.getHeroes() > 51 && accountInfo.getHeroes() <= 150) {
//                ids.add(204l);
//            }
//            if (accountInfo.getHeroes() > 150 && accountInfo.getHeroes() <= 300) {
//                ids.add(205l);
//            }
//            if (accountInfo.getHeroes() > 300 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(206l);
//            }
            skinjson.put("gameParentAttrId", 202);
            skinjson.put("gameChildAttrValue", accountInfo.getSkins());
            goodsAttrList.add(skinjson);
            ids.clear();


            //沉迷
            JSONObject chenmijson = new JSONObject();
            chenmijson.put("gameParentAttrId", 199);
            ids.add(201l);
            if (CollectionUtils.isNotEmpty(ids)) {
                String join = StringUtils.join(ids, ",");
                chenmijson.put("gameChildAttrId", join);
            }
            goodsAttrList.add(chenmijson);

            ids.clear();

            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(197l);
            } else {
                ids.add(198l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 196);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();


            JSONObject wzxiyouskinjson = new JSONObject();
            String wzryxiyouskins = LSHENConstant.wzryxiyouskins;

            jsonObjects = JSONObject.parseArray(wzryxiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiyouskinjson.put("gameParentAttrId", 142);
                String join = StringUtils.join(ids, ",");
                wzxiyouskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiyouskinjson);
            }
            ids.clear();

            //限定皮肤
            JSONObject wzxiandingskinjson = new JSONObject();
            String xiandingskins = LSHENConstant.xiandingskins;

            jsonObjects = JSONObject.parseArray(xiandingskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiandingskinjson.put("gameParentAttrId", 28);
                String join = StringUtils.join(ids, ",");
                wzxiandingskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiandingskinjson);
            }
            ids.clear();


            //星元皮肤
            JSONObject wzxingyuanskinjson = new JSONObject();
            String wzxingyuanskins = LSHENConstant.wzxingyuanskins;

            jsonObjects = JSONObject.parseArray(wzxingyuanskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxingyuanskinjson.put("gameParentAttrId", 16);
                String join = StringUtils.join(ids, ",");
                wzxingyuanskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxingyuanskinjson);
            }
            ids.clear();

            //典藏皮肤
            JSONObject wzdiancnagskinjson = new JSONObject();
            String diancangskins = LSHENConstant.diancangskins;

            jsonObjects = JSONObject.parseArray(diancangskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzdiancnagskinjson.put("gameParentAttrId", 1);
                String join = StringUtils.join(ids, ",");
                wzdiancnagskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzdiancnagskinjson);
            }
            ids.clear();

        }
        if (Objects.equals("和平精英", accountInfo.getType())) {
            params.put("goodsTitle", gameName);

            params.put("gameId", "68");

            if (Objects.equals("安卓Q", regional)) {

                params.put("gameSysId", "67");
                params.put("gameServerId", "59");
            } else if (Objects.equals("安卓WX", regional)) {

                params.put("gameSysId", "67");
                params.put("gameServerId", "60");
            } else if (Objects.equals("苹果WX", regional)) {
                params.put("gameSysId", "68");
                params.put("gameServerId", "57");
            } else if (Objects.equals("苹果Q", regional)) {
                params.put("gameSysId", "68");
                params.put("gameServerId", "58");
            } else {
                return null;
            }
            params.put("gameName", "【枪皮数量 " + accountInfo.getGuns() + "英雄数量 " + accountInfo.getSuit() + "】");

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String wzryxiyou = LSHENConstant.xiyoutaozhuang;
            List<JSONObject> jsonObjects = JSONObject.parseArray(wzryxiyou, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 389);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            JSONObject duanwei = new JSONObject();
            String duanweiStr = LSHENConstant.hpduanwei;
            jsonObjects = JSONObject.parseArray(duanweiStr, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 267);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getGuns() > -1 && accountInfo.getGuns() <= 5) {
//                ids.add(261l);
//            }
//            if (accountInfo.getGuns() > 6 && accountInfo.getGuns() <= 10) {
//                ids.add(262l);
//            }
//            if (accountInfo.getGuns() > 11 && accountInfo.getGuns() <= 20) {
//                ids.add(263l);
//            }
//            if (accountInfo.getGuns() > 21 && accountInfo.getGuns() <= 30) {
//                ids.add(264l);
//            }
//            if (accountInfo.getGuns() > 31 && accountInfo.getGuns() <= 45) {
//                ids.add(265l);
//            }
//            if (accountInfo.getGuns() > 45 && accountInfo.getGuns() <= 9999999) {
//                ids.add(266l);
//            }
            pifujson.put("gameParentAttrId", 260);
//            String join = StringUtils.join(ids, ",");
            pifujson.put("gameChildAttrValue", accountInfo.getGuns());
            goodsAttrList.add(pifujson);
            ids.clear();

            //贵族
            JSONObject guizujson = new JSONObject();
            String v1 = "V1";
            String v2 = "V2";
            String v3 = "V3";
            String v4 = "V4";
            String v5 = "V5";
            String v6 = "V6";
            String v7 = "V7";
            String v8 = "V8";
            String v9 = "V9";
            String v10 = "V9";

            if (accountInfo.getDes().contains(v1) ||
                    accountInfo.getDes().contains(v2) ||
                    accountInfo.getDes().contains(v3) ||
                    accountInfo.getDes().contains(v4) ||
                    accountInfo.getDes().contains(v5) ||
                    accountInfo.getDes().contains(v6)
            ) {
                ids.add(208l);
            }

            if (accountInfo.getDes().contains(v7)) {
                ids.add(209l);
            }
            if (accountInfo.getDes().contains(v8)) {
                ids.add(210l);
            }
            if (accountInfo.getDes().contains(v9)) {
                ids.add(211l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                String join = StringUtils.join(ids, ",");
                guizujson.put("gameChildAttrId", join);
                guizujson.put("gameParentAttrId", 207);
                goodsAttrList.add(guizujson);
            }
            ids.clear();

            JSONObject skinjson = new JSONObject();
//            if (accountInfo.getSuit() > -1 && accountInfo.getSuit() <= 50) {
//                ids.add(245l);
//            }
//            if (accountInfo.getSuit() > 51 && accountInfo.getSuit() <= 100) {
//                ids.add(246l);
//            }
//            if (accountInfo.getSuit() > 101 && accountInfo.getSuit() <= 150) {
//                ids.add(247l);
//            }
//            if (accountInfo.getSuit() > 151 && accountInfo.getSuit() <= 250) {
//                ids.add(248l);
//            }
//            if (accountInfo.getSuit() > 251 && accountInfo.getSuit() <= 351) {
//                ids.add(249l);
//            }
//            if (accountInfo.getSuit() > 351 && accountInfo.getSuit() <= 450) {
//                ids.add(250l);
//            }
//            if (accountInfo.getSuit() > 450 && accountInfo.getSuit() <= 99999999) {
//                ids.add(251l);
//            }
            skinjson.put("gameParentAttrId", 244);
            skinjson.put("gameChildAttrValue", accountInfo.getSuit());
            goodsAttrList.add(skinjson);

            ids.clear();

            //沉迷
            JSONObject chenmijson = new JSONObject();
            ids.add(243l);
            if (CollectionUtils.isNotEmpty(ids)) {
                chenmijson.put("gameParentAttrId", 241);
                String join = StringUtils.join(ids, ",");
                chenmijson.put("gameChildAttrId", join);
                goodsAttrList.add(chenmijson);
            }
            ids.clear();

            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(239l);
            } else {
                ids.add(240l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 238);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();

            JSONObject wzxiyouskinjson = new JSONObject();
            String wzryxiyouskins = LSHENConstant.remenqix;

            jsonObjects = JSONObject.parseArray(wzryxiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiyouskinjson.put("gameParentAttrId", 334);
                String join = StringUtils.join(ids, ",");
                wzxiyouskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiyouskinjson);
            }
            ids.clear();

            //限定皮肤
            JSONObject wzxiandingskinjson = new JSONObject();
            String wzryxiandingskins = LSHENConstant.remzju;

            jsonObjects = JSONObject.parseArray(wzryxiandingskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                wzxiandingskinjson.put("gameParentAttrId", 276);
                String join = StringUtils.join(ids, ",");
                wzxiandingskinjson.put("gameChildAttrId", join);
                goodsAttrList.add(wzxiandingskinjson);
            }
        }
        if (Objects.equals("原神", accountInfo.getType())) {

            params.put("goodsTitle", gameName);

            params.put("gameId", "69");

            params.put("gameSysId", "70");
            if (Objects.equals("官服", accountInfo.getRegional())) {
                params.put("gameServerId", "65");
            }
            if (Objects.equals("B服", accountInfo.getRegional())) {
                params.put("gameServerId", "66");
            }
            params.put("gameName", gameName);

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String ys5xing = LSHENConstant.ys5xing;
            List<JSONObject> jsonObjects = JSONObject.parseArray(ys5xing, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 543);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 5) {
//                ids.add(538l);
//            }
//            if (accountInfo.getHeroes() > 6 && accountInfo.getHeroes() <= 10) {
//                ids.add(539l);
//            }
//            if (accountInfo.getHeroes() > 11 && accountInfo.getHeroes() <= 20) {
//                ids.add(540l);
//            }
//            if (accountInfo.getHeroes() > 21 && accountInfo.getHeroes() <= 30) {
//                ids.add(541l);
//            }
//            if (accountInfo.getHeroes() > 31 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(542l);
//            }

            pifujson.put("gameParentAttrId", 537);
            pifujson.put("gameChildAttrValue", accountInfo.getHeroes());
            ids.clear();

            //5星角色数量
            JSONObject juese = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 5) {
//                ids.add(532l);
//            }
//            if (accountInfo.getHeroes() > 6 && accountInfo.getHeroes() <= 10) {
//                ids.add(533l);
//            }
//            if (accountInfo.getHeroes() > 11 && accountInfo.getHeroes() <= 15) {
//                ids.add(534l);
//            }
//            if (accountInfo.getHeroes() > 15 && accountInfo.getHeroes() <= 25) {
//                ids.add(535l);
//            }
//            if (accountInfo.getHeroes() > 25 && accountInfo.getHeroes() <= 9999999) {
//                ids.add(536l);
//            }
            juese.put("gameParentAttrId", 531);
            juese.put("gameChildAttrValue", accountInfo.getHeroes());
            goodsAttrList.add(juese);
            ids.clear();


            JSONObject shiming = new JSONObject();
            if (!Objects.equals(LCConstant.kehuanMial, accountInfo.getLevel())) {
                ids.add(526l);
            } else {
                ids.add(525l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 524);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }

            ids.clear();
        }
        if (Objects.equals("英雄联盟", accountInfo.getType())) {
            params.put("goodsTitle",gameName);

            params.put("gameId", "71");
            params.put("gameSysId", "71");

            String lccLOLr = LSHENConstant.lolr;
            JSONObject lOLrObject = JSONObject.parseObject(lccLOLr);
            String lOLrObjectArr = lOLrObject.getString("retData");
            List<JSONObject> rList = JSONObject.parseArray(lOLrObjectArr, JSONObject.class);
            for (JSONObject jsonObject : rList) {
                String gameServerVoList = jsonObject.getString("gameServerVoList");
                List<JSONObject> serverVoListJson = JSONObject.parseArray(gameServerVoList, JSONObject.class);
                for (JSONObject areaJson : serverVoListJson) {

                    String serverId = areaJson.getString("serverId");

                    String gameAreaVoList = areaJson.getString("gameAreaVoList");
                    List<JSONObject> areaJsonList = JSONObject.parseArray(gameAreaVoList, JSONObject.class);
                    for (JSONObject gameArea : areaJsonList) {
                        String areaName = gameArea.getString("areaName");
                        if (Objects.equals(accountInfo.getLevel(), areaName)) {
                            params.put("gameServerId", serverId);
                            params.put("gameAreaId", gameArea.getString("areaId"));
                        }
                    }
                }
            }
            params.put("gameName", "【英雄数量：" + accountInfo.getHeroes() + " 皮肤数量：" + accountInfo.getSkins());

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String hksskin = LSHENConstant.hksskin;
            List<JSONObject> jsonObjects = JSONObject.parseArray(hksskin, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 688);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();


            JSONObject duanwei = new JSONObject();
            String zhskins = LSHENConstant.zhskins;
            jsonObjects = JSONObject.parseArray(zhskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                duanwei.put("gameParentAttrId", 661);
                String join = StringUtils.join(ids, ",");
                duanwei.put("gameChildAttrId", join);
                goodsAttrList.add(duanwei);
            }
            ids.clear();

            JSONObject xiyou = new JSONObject();
            String xiyouskins = LSHENConstant.xiyouskins;
            jsonObjects = JSONObject.parseArray(xiyouskins, JSONObject.class);
            ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyou.put("gameParentAttrId", 653);
                String join = StringUtils.join(ids, ",");
                xiyou.put("gameChildAttrId", join);
                goodsAttrList.add(xiyou);
            }
            ids.clear();

            JSONObject chenmin = new JSONObject();
            chenmin.put("gameParentAttrId", 634);
            chenmin.put("gameChildAttrId", 636);
            goodsAttrList.add(chenmin);

            ids.clear();
            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(992l);
            } else {
                ids.add(993l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 991);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }
            ids.clear();

            //皮肤
            JSONObject pifujson = new JSONObject();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 30) {
//                ids.add(629l);
//            }
//            if (accountInfo.getHeroes() > 31 && accountInfo.getHeroes() <= 60) {
//                ids.add(630l);
//            }
//            if (accountInfo.getHeroes() > 61 && accountInfo.getHeroes() <= 100) {
//                ids.add(631l);
//            }
//            if (accountInfo.getHeroes() > 101 && accountInfo.getHeroes() <= 150) {
//                ids.add(632l);
//            }
//            if (accountInfo.getHeroes() > 150 && accountInfo.getHeroes() <= 999999) {
//                ids.add(633l);
//            }
            pifujson.put("gameParentAttrId", 628);
            pifujson.put("gameChildAttrValue", accountInfo.getHeroes());
            goodsAttrList.add(pifujson);
            ids.clear();
            //皮肤
            pifujson.clear();
//            if (accountInfo.getHeroes() > -1 && accountInfo.getHeroes() <= 100) {
//                ids.add(622l);
//            }
//            if (accountInfo.getHeroes() > 101 && accountInfo.getHeroes() <= 300) {
//                ids.add(623l);
//            }
//            if (accountInfo.getHeroes() > 301 && accountInfo.getHeroes() <= 500) {
//                ids.add(624l);
//            }
//            if (accountInfo.getHeroes() > 201 && accountInfo.getHeroes() <= 800) {
//                ids.add(625l);
//            }
//            if (accountInfo.getHeroes() > 801 && accountInfo.getHeroes() <= 1200) {
//                ids.add(626l);
//            }
//            if (accountInfo.getHeroes() > 1200 && accountInfo.getHeroes() <= 999999) {
//                ids.add(627l);
//            }
            pifujson.put("gameParentAttrId", 621);
            pifujson.put("gameChildAttrId", accountInfo.getSkins());
            goodsAttrList.add(pifujson);
        }
        if (Objects.equals("CF端游", accountInfo.getType())) {

            params.put("goodsTitle",  gameName);

            params.put("gameId", "72");

            params.put("gameSysId", "69");
            if (Objects.equals("东部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "61");
            }
            if (Objects.equals("南部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "62");
            }
            if (Objects.equals("西部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "63");
            }
            if (Objects.equals("北部大区", accountInfo.getRegional())) {
                params.put("gameServerId", "64");
            }
            params.put("gameName", gameName);

//            gameParentAttrId
            JSONObject xiyouwz = new JSONObject();

            String ys5xing = LSHENConstant.cfvq;
            List<JSONObject> jsonObjects = JSONObject.parseArray(ys5xing, JSONObject.class);
            List<Long> ids = new ArrayList<>();
            for (JSONObject jsonObject : jsonObjects) {
                String subAttrName = jsonObject.getString("subAttrName");
                if (des.contains(subAttrName)) {
                    Long id = jsonObject.getLong("id");
                    ids.add(id);
                }
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                xiyouwz.put("gameParentAttrId", 467);
                String join = StringUtils.join(ids, ",");
                xiyouwz.put("gameChildAttrId", join);
                goodsAttrList.add(xiyouwz);
            }
            ids.clear();

            JSONObject chenmi = new JSONObject();
            chenmi.put("gameParentAttrId", 443);
            chenmi.put("gameChildAttrId", 445);
            goodsAttrList.add(chenmi);

            ids.clear();
            JSONObject shiming = new JSONObject();
            if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                ids.add(441l);
            } else {
                ids.add(442l);
            }
            if (CollectionUtils.isNotEmpty(ids)) {
                shiming.put("gameParentAttrId", 440);
                String join = StringUtils.join(ids, ",");
                shiming.put("gameChildAttrId", join);
                goodsAttrList.add(shiming);
            }
            ids.clear();
        }

        params.put("goodsAttrList", goodsAttrList);

        params.put("goodsDesc", accountInfo.getDes());
        params.put("compensation", "1");
        params.put("channelProductCode", accountInfo.getId());
        params.put("goodsType", "0");
        params.put("qty", "1");


//        String appKey = "yuduwangluo";
//        String appSecret = "kbcyRN68obBkdwXIbwZ7eRks14tM1AsI";
        String appKey = salePartner.getSaleKey();
        String appSecret = salePartner.getOther();
        String version = "1.0";
        String timestamp = String.valueOf(new Date().getTime() / 1000);
        Map<String, Object> paramReq = new HashMap<>();
        paramReq.put("appKey", appKey);
        paramReq.put("timestamp", timestamp);
        paramReq.put("version", version);
        paramReq.put("paramJson", JSONObject.toJSONString(params));
        log.info("paramJson={}", JSONObject.toJSONString(params));

        String sign = algSign(appKey, appSecret, timestamp, version, JSONObject.toJSONString(params));
//        params.put("sign", sign);
        paramReq.put("sign", sign);
        return paramReq;
    }


    @Override
    public AjaxResult delGame(AccountInfo accountInfo, Long userId, SalePartner sa) {

        String path = "/apiProduct/del";

        List<Map<String, Object>> goodsList = new ArrayList<>();
        Map<String, Object> paramsDel = new HashMap<>();
        paramsDel.put("goodsNo", accountInfo.getLeishenid());
        goodsList.add(paramsDel);
        Map<String, Object> map = new HashMap<>();
        map.put("goodsList", goodsList);
//        String appKey = "yuduwangluo";
//        String appSecret = "kbcyRN68obBkdwXIbwZ7eRks14tM1AsI";

        String appKey = sa.getSaleKey();
        String appSecret = sa.getOther();
        String version = "1.0";
        String timestamp = String.valueOf(new Date().getTime() / 1000);
        Map<String, Object> paramReq = new HashMap<>();
        paramReq.put("appKey", appKey);
        paramReq.put("timestamp", timestamp);
        paramReq.put("version", version);
        paramReq.put("paramJson", JSONObject.toJSONString(map));
        log.info("paramJson={}", JSONObject.toJSONString(map));

        String sign = algSign(appKey, appSecret, timestamp, version, JSONObject.toJSONString(map));
//        params.put("sign", sign);
        paramReq.put("sign", sign);

        Map<String, Object> header = new HashMap<>();
        header.put("reqChannel", 4);

        log.info("雷神删除接口请求参数={}", JSONObject.toJSONString(paramReq));
        String response = HttpUtils.doPostForm(sa.getTwoOther() + path, paramReq, header);
        if (StringUtils.isEmpty(response)) {
            throw new GlobalException("请求接口失败");
        }
        log.info("雷神删除接口返回参数={}", JSONObject.toJSONString(response));
        JSONObject resultJson = JSONObject.parseObject(response);
        Map<String, Object> result = new HashMap<>();

        if (!"true".equals(resultJson.getString("success"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
        }

        result.put("req", JSONObject.toJSONString(paramReq));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));
        return AjaxResult.success(result);
    }

    public void upGame(String goodsNo, SalePartner sa) {

        String path = "/apiProduct/up";

        List<Map<String, Object>> goodsList = new ArrayList<>();
        Map<String, Object> paramsDel = new HashMap<>();
        paramsDel.put("goodsNo", goodsNo);
        goodsList.add(paramsDel);
        Map<String, Object> map = new HashMap<>();
        map.put("goodsList", goodsList);
//        String appKey = "yuduwangluo";
//        String appSecret = "kbcyRN68obBkdwXIbwZ7eRks14tM1AsI";

        String appKey = sa.getSaleKey();
        String appSecret = sa.getOther();
        String version = "1.0";
        String timestamp = String.valueOf(new Date().getTime() / 1000);
        Map<String, Object> paramReq = new HashMap<>();
        paramReq.put("appKey", appKey);
        paramReq.put("timestamp", timestamp);
        paramReq.put("version", version);
        paramReq.put("paramJson", JSONObject.toJSONString(map));
        log.info("paramJson={}", JSONObject.toJSONString(map));

        String sign = algSign(appKey, appSecret, timestamp, version, JSONObject.toJSONString(map));
//        params.put("sign", sign);
        paramReq.put("sign", sign);

        Map<String, Object> header = new HashMap<>();
        header.put("reqChannel", 4);

        log.info("雷神上架接口请求参数={}", JSONObject.toJSONString(paramReq));
        String response = HttpUtils.doPostForm(sa.getTwoOther() + path, paramReq, header);
        if (StringUtils.isEmpty(response)) {
            throw new GlobalException("请求接口失败");
        }
        log.info("雷神上架接口返回参数={}", JSONObject.toJSONString(response));
        JSONObject resultJson = JSONObject.parseObject(response);
        Map<String, Object> result = new HashMap<>();

        if (!"true".equals(resultJson.getString("success"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
        }

        result.put("req", JSONObject.toJSONString(paramReq));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));
    }


    public static void main(String[] args) {

        String appKey = "yuduwangluo";
        String appSecret = "kbcyRN68obBkdwXIbwZ7eRks14tM1AsI";
        String version = "1.0";
        String timestamp = String.valueOf(new Date().getTime() / 1000);
        Map<String, Object> params = new LinkedHashMap<>();
        params.put("appKey", appKey);
        params.put("timestamp", timestamp);
        params.put("version", version);
        params.put("paramJson", "");

        String baseUrl = "http://test-www.leishenshangcheng.com/webapi";
        String getFameList = "/apiProduct/getGameList";

        Map<String, Object> header = new HashMap<>();
        header.put("reqChannel", 4);


//        String response = HttpUtils.doPostForm(baseUrl + getFameList, params, header);

        // {"retTime":"2023-03-07 21:13:18","success":true,"trackId":"b70477cea4104067a80753c5fd242b83","retData":[{"gameType":2,"gameName":"王者荣耀","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581266/1204/王者荣耀.webp","headWord":"W","hotStatus":1,"id":67,"sort":100,"gameOtherName":"王者/WZRY/WZ"},{"gameType":1,"gameName":"和平精英","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581445/6582/和平精英.webp","headWord":"H","hotStatus":1,"id":68,"sort":99,"gameOtherName":"和平/HP"},{"gameType":2,"gameName":"原神","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581439/8129/原神.webp","headWord":"Y","hotStatus":1,"id":69,"sort":97,"gameOtherName":""},{"gameType":1,"gameName":"地下城与勇士","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581426/182/DNF.webp","headWord":"D","hotStatus":1,"id":70,"sort":96,"gameOtherName":"DNF/dnf"},{"gameType":1,"gameName":"英雄联盟","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677641969/248/8pqgxt.jpg","headWord":"Y","hotStatus":1,"id":71,"sort":95,"gameOtherName":"lol/LOL/撸啊撸"},{"gameType":2,"gameName":"穿越火线","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581410/6232/6aprxa.jpg","headWord":"C","hotStatus":1,"id":72,"sort":94,"gameOtherName":"CF"},{"gameType":2,"gameName":"枪战王者","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581397/882/枪战王者.webp","headWord":"Q","hotStatus":1,"id":73,"sort":93,"gameOtherName":"CFM/cfm"},{"gameType":2,"gameName":"火影忍者","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581390/2553/火影.webp","headWord":"H","hotStatus":1,"id":74,"sort":92,"gameOtherName":"火影"},{"gameType":1,"gameName":"绝地求生","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1675655749/1228/u3nuf6.png","headWord":"J","hotStatus":1,"id":75,"sort":91,"gameOtherName":"吃鸡/PUBG/pubg"},{"gameType":1,"gameName":"永劫无间","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581378/7710/永劫无间.webp","headWord":"Y","hotStatus":1,"id":76,"sort":90,"gameOtherName":"永劫"},{"gameType":1,"gameName":"Apex英雄","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581370/1666/Apex.webp","headWord":"A","hotStatus":1,"id":77,"sort":89,"gameOtherName":"APEX/apex"},{"gameType":2,"gameName":"光遇","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677641848/2704/bw2n1y.jpg","headWord":"G","hotStatus":1,"id":78,"sort":88,"gameOtherName":""},{"gameType":2,"gameName":"三国杀","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581355/9843/三国杀.webp","headWord":"S","hotStatus":1,"id":79,"sort":87,"gameOtherName":""},{"gameType":2,"gameName":"第五人格","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581348/737/第五人格.webp","headWord":"D","hotStatus":1,"id":80,"sort":86,"gameOtherName":""},{"gameType":2,"gameName":"QQ飞车手游","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581337/6841/QQ飞车手游.webp","headWord":"Q","hotStatus":1,"id":81,"sort":85,"gameOtherName":""},{"gameType":2,"gameName":"香肠派对","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581328/7549/香肠派对.webp","headWord":"X","hotStatus":1,"id":82,"sort":84,"gameOtherName":""},{"gameType":2,"gameName":"蛋仔派对","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581320/5013/蛋仔派对.webp","headWord":"D","hotStatus":1,"id":83,"sort":83,"gameOtherName":""},{"gameType":2,"gameName":"金铲铲之战","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581309/1231/19aoot.jpg","headWord":"J","hotStatus":1,"id":84,"sort":82,"gameOtherName":""},{"gameType":2,"gameName":"LOL手游","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581301/838/lr3qp8.jpg","headWord":"L","hotStatus":1,"id":85,"sort":81,"gameOtherName":"英雄联盟手游"},{"gameType":1,"gameName":"天涯明月刀","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581293/7222/ffud66.png","headWord":"T","hotStatus":-1,"id":86,"sort":80,"gameOtherName":"天刀"},{"gameType":1,"gameName":"逆战","createTime":"2023-02-28 17:54:43","gameUrl":"https://test1-dfs01.nn.com/v2/default/1677581283/4044/逆战.webp","headWord":"N","hotStatus":-1,"id":87,"sort":79,"gameOtherName":"NZ"},{"gameType":1,"gameName":"和平精英1","createTime":"2023-03-02 09:45:25","gameUrl":"https://test1-dfs01.nn.com/v2/default/1675670324/2713/8wx20l.jpg","headWord":"H","hotStatus":1,"id":88,"sort":101,"gameOtherName":"吃鸡游戏"},{"gameType":2,"gameName":"球球大作战","createTime":"2023-03-06 15:05:51","gameUrl":"https://test1-dfs01.nn.com/v2/default/1678086346/9339/d156jh.png","headWord":"Q","hotStatus":-1,"id":89,"sort":80,"gameOtherName":"球球"}],"retCode":"100","retMsg":"操作成功"}

        String getServerAreaList = "/apiProduct/getServerAreaList";
        String attrListByGameId = "/apiProduct/attrListByGameId";

        JSONObject paramJson = new JSONObject();
        paramJson.put("gameId", 67);
        params.put("paramJson", JSONObject.toJSONString(paramJson));
        String sign = algSign(appKey, appSecret, timestamp, version, JSONObject.toJSONString(paramJson));
        params.put("sign", sign);

        String response = HttpUtils.doPostForm(baseUrl + attrListByGameId, params, header);

        System.out.println(response);
    }

    public static String algSign(String appKey, String appSecret, String timestamp, String version, String paramJson) {
        StringBuilder sf = new StringBuilder();
        sf.append(appSecret);
        sf.append("appKey");
        sf.append(appKey);
        sf.append("paramJson");
        sf.append(paramJson);
        sf.append("timestamp");
        sf.append(timestamp);
        sf.append("version");
        sf.append(version);
        sf.append(appSecret);
        String algSign = DigestUtils.md5Hex(sf.toString());
        log.info("计算签名结果:{}", algSign);
        return algSign;
    }

}
